/**
 * 
 */
	//这里是验证码
$(function(){
		function changePictrueCode(){
			$(".loginImgCode").prop("src","PictureCode/loginCode?"+Math.random());
		}
		$(".loginImgCode").click(function(){
			changePictrueCode();
		});
});
		//选择框
		layui.use('element', function(){
		var element = layui.element;	  
	  //一些事件监听0,.
	  });                                                        
		//验证密码是否相同,不同无法注册
		function validate(){
			var pwd3 =document.getElementById("password3").value;
			var pwd4 =document.getElementById("password4").value;
			if(pwd3==pwd4 ){
				 document.getElementById("tishi2").innerHTML="<font color='blue'>两次密码相同</font>";
				 document.getElementById("button2").disabled=false;	
			}else{
				 document.getElementById("tishi2").innerHTML="<font color='red'>两次密码不相同</font>";
				 document.getElementById("button2").disabled=true;		
			}
		};
		function validate1(){
			var pwd1 =document.getElementById("password1").value;
			var pwd2 =document.getElementById("password2").value;
			if(pwd1==pwd2 ){
				 document.getElementById("tishi1").innerHTML="<font color='blue'>两次密码相同</font>";
				 document.getElementById("button1").disabled=false;	
			}else{
				 document.getElementById("tishi1").innerHTML="<font color='red'>两次密码不相同</font>";
				 document.getElementById("button1").disabled=true;		
			}			
		}
		function validate3(){
			var pwd5 =document.getElementById("password5").value;
			var pwd6 =document.getElementById("password6").value;
			if(pwd5==pwd6 ){
				 document.getElementById("tishi3").innerHTML="<font color='blue'>两次密码相同</font>";
				 document.getElementById("button3").disabled=false;	
			}else{
				 document.getElementById("tishi3").innerHTML="<font color='red'>两次密码不相同</font>";
				 document.getElementById("button3").disabled=true;		
			}			
		}		
		//邮件获取验证码
		function sendMail(){
			$.ajax({
				url:"/user/sendMail",
				type:"post",
				data:{
					mail:$("#mail").val()
				}
			});			
		}
		//邮件注册
		function mailRegister(){
			$.ajax({
				url:"/user/mail",
				type:"post",
				data:{
					umail:$("#mail").val(),
					pwd:$("#password5").val(),
					number:$("#number").val(),
					userRole:$("input[name='character']:checked").val()
				},
				success:function(data){					
					 if(data.indexOf("成功")!=-1){
						alert(data);
						window.location.href = 'http://localhost:8080/index.html';
					}if(data.indexOf("为空")!=-1){
						alert(data);
						window.location.reload();
					}if(data.indexOf("失败")!=-1){
						alert(data);
						window.location.reload();
					}
				}
			});
		}
		//手机注册
		// 局部取得验证码
		function creatYZM() {
			alert("验证码发送中");
			var options = {  
					url: "../user/creatYZM/",  
					type: 'post', 
					dataType: 'json',  
			         data:{
			    	  phoneNum:$("#account1").val()
					    },
					    success: function () {  			    	    
					}  
			};  		
			   $.ajax(options);
			}		
		// 局部验证验证码
		function confirmYZM() {
			    var options = {  
			    url: "../user/confirmYZM/",  
			    type: 'post', 			     
			    data:{
			    	sryzm:$("#sryzm").val(),
			    	uphone:$("#account1").val(),
			    	pwd:$("#password1").val(),
			    	userRole:$("input[name='character']:checked").val()
			    },    
			    success: function (data) {  			    	
					if (data.indexOf("成功")!=-1){
						alert(data);
						window.location.href = 'http://localhost:8080/index.html';
					}if(data.indexOf("为空")!=-1){
						alert(data);
						window.location.reload();
					}if(data.indexOf("失败")!=-1){
						alert(data);
						window.location.reload();
					}
			    }  		     
			};  
			   $.ajax(options);
			}
		//个性注册
		function register(){
			$.ajax({
				url:"/user/register",
				type:"post",
				data:{
					account:$("#account").val(),
					pwd:$("#password3").val(),
					loginImgCode:$("#loginCode").val(),
					userRole:$("input[name='character']:checked").val()
				},
				success:function(data){
					if(data.indexOf("成功")!=-1){
						alert(data);
						window.location.href = 'http://localhost:8080/index.html';
					}if(data.indexOf("为空")!=-1){
						alert(data);
						window.location.reload();
					}if(data.indexOf("失败")!=-1){
						alert(data);
						window.location.reload();
					}
				}
			});
		}
		